package cn.tedu.medicalappointmentsystemk.dao.persist.repository.impl;

import cn.tedu.medicalappointmentsystemk.dao.persist.mapper.DepartmentMapper;
import cn.tedu.medicalappointmentsystemk.dao.persist.repository.DepartmentRepository;
import cn.tedu.medicalappointmentsystemk.pojo.bo.DepartmentSelectBO;
import cn.tedu.medicalappointmentsystemk.pojo.po.DepartmentPO;
import cn.tedu.medicalappointmentsystemk.pojo.vo.DepartmentSelectDoctorVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class DepartmentRepositoryImpl implements DepartmentRepository {
    @Autowired
    DepartmentMapper departmentMapper;

    @Override
    public Integer addDepartment(DepartmentPO departmentPO) {
        return departmentMapper.insert(departmentPO);
    }

    @Override
    public Integer selectByName(String name) {
        QueryWrapper<DepartmentPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("name",name);
        return departmentMapper.selectCount(queryWrapper);
    }

    @Override
    public Integer update(DepartmentPO departmentPO) {
        return departmentMapper.updateById(departmentPO);
    }

    @Override
    public DepartmentPO selectById(Long id) {
        return departmentMapper.selectById(id);
    }

    @Override
    public List<DepartmentPO> select() {
        return departmentMapper.selectList(null);
    }

    @Override
    public Integer deleteById(Long id) {
        return departmentMapper.deleteById(id);
    }

    @Override
    public List<DepartmentSelectDoctorVO> selectDoctorByDepartmentId(Long id) {
        return departmentMapper.selectDoctorByDepartmentId(id);
    }

    @Override
    public List<DepartmentPO> select(Long id) {
        return departmentMapper.selectLevel(id);
    }

    @Override
    public Page<DepartmentSelectBO> selectDepartment() {
        return departmentMapper.selectDepartment();
    }

    @Override
    public Page<DepartmentSelectBO> searchLastWeek() {
        return departmentMapper.searchLastWeek();
    }

    @Override
    public Page<DepartmentSelectBO> searchLastMonth() {
        return departmentMapper.searchLastMonth();
    }

    @Override
    public Page<DepartmentSelectBO> searchToday() {
        return departmentMapper.searchToday();
    }

    @Override
    public List<DepartmentSelectBO> departmentSelectByName(String name) {
        return departmentMapper.departmentSelectByName(name);
    }
}
